package com.example.database.service.impl;

import com.example.database.dao.StudentDao;
import com.example.database.entity.*;
import com.example.database.enums.Status;
import com.example.database.service.StudentService;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpSession;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class StudentServiceImpl implements StudentService
{
    @Resource
    private StudentDao studentDao;

    @Override
    public boolean login(Integer studentId, String password, HttpSession session)
    {
        Student student = studentDao.findStudentById(studentId);
        if (student != null && password.equals(student.getPassword()))
        {
            session.setAttribute("student", student);
            return true;
        }
        return false;
    }

    @Override
    public Boolean addStudent(Student student)
    {
        return studentDao.addStudent(student);
    }

    @Override
    public Boolean deleteStudentById(Integer studentId)
    {
        return studentDao.deleteStudentById(studentId);
    }

    @Override
    public Boolean updateStudent(Student student)
    {
        return studentDao.updateStudent(student);
    }

    @Override
    public Student findStudentById(Integer studentId)
    {
        return studentDao.findStudentById(studentId);
    }

    @Override
    public ClassInstructor findClassInstructorByStudentId(Integer studentId)
    {
        return studentDao.findClassInstructorByStudentId(studentId);
    }

    @Override
    public List<Student> findStudentByCampus(Integer campusId)
    {
        return studentDao.findStudentByCampus(campusId);
    }

    @Override
    public List<InOutLog> findLogByCampus(Integer campusId)
    {
        return studentDao.findLogByCampus(campusId);
    }

    @Override
    public Boolean addAdmissionForm(AdmissionForm admissionForm)
    {
        return studentDao.addAdmissionForm(admissionForm);
    }

    @Override
    public Boolean addLeavingForm(LeavingForm leavingForm)
    {
        return studentDao.addLeavingForm(leavingForm);
    }

    @Override
    public Boolean addHealthForm(HealthForm healthForm)
    {
        return studentDao.addHealthForm(healthForm);
    }

    @Override
    public List<HealthForm> findNDaysHealthInfo(Integer studentId, Integer nDays)
    {
        return studentDao.findNDaysHealthInfo(studentId, nDays);
    }

    @Override
    public List<AdmissionForm> findAdmissionFormByStudentId(Integer studentId, Status state)
    {
        return studentDao.findAdmissionFormByStudentId(studentId, state);
    }

    @Override
    public List<LeavingForm> findLeavingFormByStudentId(Integer studentId, Status state)
    {
        return studentDao.findLeavingFormByStudentId(studentId, state);
    }

    @Override
    public List<Student> findMostAdmissionStudentAll()
    {
        return studentDao.findMostAdmissionStudentAll();
    }

    @Override
    public List<Student> findMostAdmissionStudentByDept(Integer deptId)
    {
        return studentDao.findMostAdmissionStudentByDept(deptId);
    }

    @Override
    public List<Student> findMostAdmissionStudentByClass(Integer classId)
    {
        return studentDao.findMostAdmissionStudentByClass(classId);
    }

    @Override
    public String OutOfSchoolTimeOneYearByStudentId(Integer studentId)
    {
        return studentDao.OutOfSchoolTimeOneYearByStudentId(studentId);
    }

    @Override
    public Integer regOutButInSchoolNum()
    {
        return studentDao.regOutButInSchoolNum();
    }

    @Override
    public List<Student> regOutButInSchoolStudentInfo()
    {
        return studentDao.regOutButInSchoolStudentInfo();
    }

    @Override
    public Integer outSchoolStudentNum()
    {
        return studentDao.outSchoolStudentNum();
    }

    @Override
    public List<Student> outSchoolStudentInfo()
    {
        return studentDao.outSchoolStudentInfo();
    }
}
